
//
//  MemberQuestionController.m
//  yameishe3
//
//  Created by pro on 2017/3/7.
//  Copyright © 2017年 yameishe. All rights reserved.
//

#import "MemberQuestionController.h"
#import "YMSMemberManager.h"
#import "QuestionView.h"
@interface MemberQuestionController ()<UIScrollViewDelegate>
{
    __weak IBOutlet UIScrollView *_scrollView;
    QuestionView *_questionView;
    NSDictionary *_questionDic;
    
}
@end

@implementation MemberQuestionController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self controllerSetting];

    [self.view layoutIfNeeded];
    _questionView = [[[NSBundle mainBundle]loadNibNamed:@"QuestionView" owner:self options:nil] firstObject];
    [_scrollView addSubview:_questionView];
    [_questionView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_scrollView);
        make.leading.trailing.equalTo(self.view);
        make.height.equalTo(@([QuestionView viewHeight]));
    }];
    [_questionView setCallbackDidSubmit:^(NSDictionary *dic) {
    
    }];
    [self requestQuestion];
    _scrollView.contentSize = CGSizeMake(0, _questionView.height);
}
-(void)requestQuestion
{
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]init];
    [dic setValue:[YMSMember loginMember].token forKey:@"_token"];
   [[YMSMemberManager alloc]MemberGetQuestionWithDic:dic successBlock:^(NSDictionary *result) {
       _questionDic = [NSDictionary dictionaryWithDictionary:result[@"data"]];
       _questionView.questionDic =(NSMutableDictionary*) _questionDic;
   } failureBlock:^(NSString *error) {
    
   }];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
#pragma mark UIScrollViewDelegate
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    for (UIView *view in _questionView.subviews) {
        for (UIView * subView in view.subviews) {
            [subView resignFirstResponder];
        }
        [view resignFirstResponder];
    }
}

@end
